﻿using Entity.Models;
using IRepositorys;
using IServices;

namespace Services;

public class UserService : BaseService<SysUser>, IUserService
{
    private readonly IBaseRepository<SysUser> repository;

    public UserService(IBaseRepository<SysUser> repository)
        : base(repository)
    {
        this.repository = repository;
    }

    /// <summary>
    ///     用户登录
    /// </summary>
    /// <param name="userName"></param>
    /// <param name="password"></param>
    /// <returns></returns>
    public async Task<SysUser> Login(string userName, string password)
    {
        return await repository.GetFirstAsync(u =>
            u.UserName == userName && u.Password == password
        );
    }
}